//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "player\fn_playerDist.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;
private ["_result","_pos","_dist"];
_result = 1000000;
_pos = _this;
if (IS_ARRAY(_this)) then {
	if (count _this == 1) then {
		_pos = _this select 0;
		if (IS_OBJECT(_pos)) then {
			_pos = position _pos;
		};
		if (IS_STRING(_pos)) then {
			_pos = markerPos _pos;
		};
	};
};
if (IS_OBJECT(_this)) then {
	_pos = position _this;
};
if (IS_STRING(_this)) then {
	_pos = markerPos _this;
};
if (IS_ARRAY(_pos) && {count _pos >= 2}) then {
	{
		_dist = [_pos, vehicle(_x)] call FFUNC(distTo);
		if (_dist < _result) then { _result = _dist };
	} foreach (call FFUNC(allPlayers));
};
TRACE_1("End",_result);
TMFPROFILERSTOP;
_result;